package com.interview.ujiuye6;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * Copyright (C), 2018-2020
 * FileName: Demo2
 * Author:   kongfanyu
 * Date:     2020/11/7 15:51
 */
public class Demo2 {
    private static List<Employee> list = new ArrayList<>();
    static {
        list.add( new Employee("张三",38,5500.00) );
        list.add( new Employee("李四",30,4500.00) );
        list.add( new Employee("王五",48,6500.00) );
        list.add( new Employee("赵六",28,8500.00) );
        list.add( new Employee("赵六",28,8500.00) );
        list.add( new Employee("赵六",28,8500.00) );
        list.add( new Employee("赵六",28,8500.00) );
    }

    public static void main(String[] args) {
        List<String> list1 = Arrays.asList("aaa","bbb","ccc","ddd");
        Stream<String> stringStream = list1.stream().map(s -> s.toUpperCase());
        stringStream.forEach(System.out::println);

        //filter过滤方法
        //Stream<Employee> stream = list.stream().filter((e) -> e.getAge() > 35);
        //stream.forEach(System.out::println);

        System.out.println("---------------");
        list.stream().sorted((e1,e2) ->{
            if(e1.getAge().equals(e2.getAge())) {
                return e1.getName().compareTo(e2.getName());
            }else {
                return -e1.getAge().compareTo(e2.getAge());
            }
        }).forEach(System.out::println);

    }
}
